package com.hyst.apicontroller.demo;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hyst.model.UserModel;
import com.hyst.repository.UserRepository;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;


@Api(value = "UserController", description = "用户基本信息")
@RestController
@RequestMapping(value="users/basic")     // 通过这里配置使下面的映射都在/users下，可去除
public class UserController {

	
	@Autowired
	UserRepository userRepository;

	@ApiOperation(value = "获取所有用户列表")
	@GetMapping("all")
	public List<UserModel> getUsers() {
		return userRepository.findAll();
	}

	@ApiOperation(value = "获取单个人员信息")
	@GetMapping("getOne/{uniqueid}")
	public UserModel getOne(@PathVariable @ApiParam(value = "用户唯一id", required = true) String uniqueid) {
		return userRepository.findOneById(uniqueid);
	}
	
	
//	@ApiOperation(value = "获取机密用户列表")
//	@ApiImplicitParam(name = "user", value = "用户详细实体user", required = false, dataType = "User")
//	@GetMapping("jimi")
//	public List<UserModel> getUserName() {
//		//return userRepository.getUsers("机密");
//		return userRepository.getUsers("机密");
//	}
	
}